<?php

namespace app\common\model\search;

trait FollowTrialSearch
{
    //随访日期
    public function searchFollowDateAttr($query, $value, $data)
    {
        $where = [];
        if ((isset($value[0]) && !empty($value[0])) && $value[0] <> 'null') {
            $where[] = ['follow_date', '>=', $value[0]];
        }

        if ((isset($value[1]) && !empty($value[1])) && $value[1] <> 'null') {
            $where[] = ['follow_date', '<=', $value[1]];
        }
        return $query->where($where);
    }

    //随访医生
    public function searchDoctorAttr($query, $value, $data)
    {
        return $query->whereLike('creator_name', trim($value));
    }

    //项目编号
    public function searchProjectNoAttr($query, $value, $data)
    {
        return $query->where('project_no', trim($value));
    }

    //入组编号
    public function searchEnrollmentNoAttr($query, $value, $data)
    {
        return $query->where('enrollment_no', trim($value));
    }

    //患者
    public function searchNameAttr($query, $value, $data)
    {
        return $query->whereLike('name', trim($value));
    }
}